import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OpenKeyVO, OpenKeyForm, OpenKeyQuery } from '@/api/gpt/openKey/types';

/**
 * 查询模型配置列表
 * @param query
 * @returns {*}
 */

export const listOpenKey = (query?: OpenKeyQuery): AxiosPromise<OpenKeyVO[]> => {
  return request({
    url: '/gpt/open/key/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询模型配置详细
 * @param id
 */
export const getOpenKey = (id: string | number): AxiosPromise<OpenKeyVO> => {
  return request({
    url: '/gpt/open/key/' + id,
    method: 'get'
  });
};

/**
 * 新增模型配置
 * @param data
 */
export const addOpenKey = (data: OpenKeyForm) => {
  return request({
    url: '/gpt/open/key',
    method: 'post',
    data: data
  });
};

/**
 * 修改模型配置
 * @param data
 */
export const updateOpenKey = (data: OpenKeyForm) => {
  return request({
    url: '/gpt/open/key',
    method: 'put',
    data: data
  });
};

/**
 * 删除模型配置
 * @param id
 */
export const delOpenKey = (id: string | number | Array<string | number>) => {
  return request({
    url: '/gpt/open/key/' + id,
    method: 'delete'
  });
};
